package com.study.javassist.junit;

import java.io.File;

import org.junit.Test;

/**
* @Name: GetProjectPathTest
* @Description: 获取项目路径测试类
* @Author: 李超	lc_jack@foxmail.com
* @CreateDate: 2017-1-19 下午9:41:47 
* @Version: V1.0
 */
public class GetProjectPathTest {
	
	/**
	* @Name: getProjectPath
	* @Description: 获取项目路径
	* @Author: 李超	lc_jack@foxmail.com
	* @Version: V1.0
	* @CreateDate: 2017-1-19 下午9:43:47
	* @Parameters: 
	* @Return: void
	 */
	@Test
	public void getProjectPath() {
		//获取项目路径
		String projectPath = new File("").getAbsolutePath() ;
		System.out.println(projectPath);
		//获取类根目录路径
		String rootPath = this.getClass().getResource("/").getPath() ;
		String rootPath2 = this.getClass().getClassLoader().getResource("").getPath() ;
		String rootPath3 = this.getClass().getClassLoader().getSystemResource("").getPath() ;
		String rootPath4 = Thread.currentThread().getContextClassLoader().getResource("").getFile().toString() ;
		System.out.println(rootPath);
		System.out.println(rootPath2);
		System.out.println(rootPath3);
		System.out.println(rootPath4);
		//获取类当前路径
		String currentPath = this.getClass().getResource(".").getPath() ;
		String currentPath2 = this.getClass().getResource("").getPath() ;
		System.out.println(currentPath);
		System.out.println(currentPath2);
		//获取类当前路径的上级目录路径
		String parentPath = this.getClass().getResource("../").getPath() ;
		System.out.println(parentPath);
 	}
	
	

}
